package com.shanling.shanlingcontroller.persenter

import android.content.Context

import com.shanling.shanlingcontroller.music.player.SongLoader
import com.shanling.shanlingcontroller.persenter.contract.SongFragmentContract
import org.jetbrains.anko.AnkoAsyncContext
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread



/**
 * Created by yonglong on 2018/1/7.
 */

class SongsPresenter
constructor() : RxPresenter<SongFragmentContract.View>(), SongFragmentContract.Presenter {
    override fun loadSongs(context: Context) {
        mView?.showLoading()
        doAsync {
            val data = SongLoader.getLocalMusic(context)
            uiThread {
                mView?.hideLoading()
                mView?.showSongs(data)
                if (data.size == 0) {
                    mView?.setEmptyView()
                }
            }
        }

    }
}
